package com.kx.yooli.kx.wechat.config.manager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author john_sqwen-childe.wen
 * @date 2024/3/28
 * @PROJECT_NAME wechat
 * @description create MessageBeanManager by john_sqwen
 * and BeanManager  value is
 */
@Component
public class MessageBeanManager implements ApplicationContextAware {
    private  final Logger log = LoggerFactory.getLogger(MessageBeanManager.class);
    private   ApplicationContext applicationContext = null;
    @Override
    public void setApplicationContext( ApplicationContext applicationContext) throws BeansException {
        log.info("private context value is {},param context value is {}",this.applicationContext,applicationContext);
        this.applicationContext = applicationContext;
    }
    public   ApplicationContext getApplicationContext() { return applicationContext; }

    public   Object getBean(String name) {
        return applicationContext.getBean(name);
    }

    public   <T> T getBean(Class<T> clazz) {
        return applicationContext.getBean(clazz);
    }
}
